package adc.app.ui.wicket.table;

import org.apache.wicket.Component;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IStyledColumn;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;

public class StyledColumn<T> implements IStyledColumn<T> {

	private static final long serialVersionUID = 1L;

	private final IColumn<T> decoratedColumn;
	
	private String cssClass;
	
	public StyledColumn(IColumn<T> decoratedColumn) {
		super();
		this.decoratedColumn = decoratedColumn;
	}

	@Override
	public Component getHeader(String componentId) {
		return decoratedColumn.getHeader(componentId);
	}

	@Override
	public String getSortProperty() {
		return decoratedColumn.getSortProperty();
	}

	@Override
	public boolean isSortable() {
		return decoratedColumn.isSortable();
	}

	@Override
	public void populateItem(Item<ICellPopulator<T>> cellItem,
			String componentId, IModel<T> rowModel) {
		decoratedColumn.populateItem(cellItem, componentId, rowModel);
	}

	@Override
	public void detach() {
		decoratedColumn.detach();
		
	}

	@Override
	public final String getCssClass() {
		return cssClass;
	}

	public final StyledColumn<T> setCssClass(String cssClass) {
		this.cssClass = cssClass;
		return this;
	}

	public final IColumn<T> getDecoratedColumn() {
		return decoratedColumn;
	}
}
